package com.zsummer.zero.design.create.factory;

/**
 * 工厂方法模式
 * @author zhouyujiang
 *
 */
public class Demo2 {

	public static void main(String[] args) {
		GirlFactory girlFactory = new GirlFactory();
		Person girl = girlFactory.createPerson();
		girl.say();
	}
	
}

abstract class AbstractPersonFactory {
	abstract Person createPerson();
}

class GirlFactory extends AbstractPersonFactory {

	@Override
	Person createPerson() {
		return new Girl();
	}
	
}

class BoyFactory extends AbstractPersonFactory {

	@Override
	Person createPerson() {
		return new Boy();
	}
	
}